﻿using System.Web.Mvc;
using System.Web.Routing;

namespace YuYuKiCms.Internet
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            const string patternLanguage = "^[a-z]{2}$";

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            var localizingRoute = new AutoLocalizingRoute("{language}/{controller}/{action}/{url}",
                new {language = "fr", controller = "Home", action = "Redirect", url = UrlParameter.Optional},
                new {language = patternLanguage});

            var defaultRoute = new AutoLocalizingRoute("{controller}/{action}/{id}",
                new {controller = "Home", action = "Redirect", id = UrlParameter.Optional}, null);

            RouteTable.Routes.Add("LocalizeRoute", localizingRoute);
            RouteTable.Routes.Add("Default", defaultRoute);
        }
    }
}